function search(){
	this.page = 1;
	this.size = 10;
	this.orderId = null;
}

var perfix = "http://localhost:8080"

function result (){
	this.orders = []
}

var search = new search();
var result = new result();
$.ajax({
		url: perfix + "/order/listAll",
		data: JSON.stringify(search),
		type: 'post',
		headers: {
			'Authorization': localStorage.getItem("token")
		},
		contentType: 'application/json',
		success: function(data) {
			if (data.code == 10006) {
				localStorage.clear();
				$(window).attr('location', "login.html");
			}
			
			for(var i =0;i<data.data.records.length;i++){
				result.orders[i] = {
					"id":data.data.records[i].id,
					"orderPrice":data.data.records[i].orderPrice,
					"orderStatus":data.data.records[i].orderStatus,
					"username":data.data.records[i].username
				}
			}
			console.log(result.orders);
			//数据渲染
			for(var i = 0;result.orders.length;i++){
				if(result.orders[i].orderStatus == 0){
					result.orders[i].orderStatus = "已失效"
				}
				if(result.orders[i].orderStatus == 1){
					result.orders[i].orderStatus = "待付款"
				}
				if(result.orders[i].orderStatus == 2){
					result.orders[i].orderStatus = "待收货"
				}
				if(result.orders[i].orderStatus == 3){
					result.orders[i].orderStatus = "待评价"
				}
				if(result.orders[i].orderStatus == 4){
					result.orders[i].orderStatus = "已完成"
				}
				$("tbody").append($(
					`
					<tr>
						<td>${result.orders[i].id}</td>
						<td>${result.orders[i].orderPrice}</td>
						<td><span class="label label-success">${result.orders[i].orderStatus}</span></td>
						<td>${result.orders[i].username}</td>
					
						<td><span class="label label-info">详情</span><span class="label label-danger">删除</span></td>
					
					</tr>
				`
				))
			}
			
		
			
		}
	})

